<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>8、将 object 对象中的 key 和 value 互换。 </title>
</head>

<body>
  <script>
    let obj = {
      name: 'nb',
      age: '12'
    }
    for (let k in obj) {
      let value = obj[k]; //将原来的value赋值给一个变量
      obj[value] = k;
      delete obj[k]; // 删除原来的属性
    }
    console.log(obj)

  </script>
</body>

</html>